namespace Cik.Gapi4Net.Domain.Input
{
    using System.Text;
    using Contract;

    public class Translate : EntityBase, ITranslate
    {
        public string SourceLanguage { get; set; }

        public string LanguagePair { get; set; }

        public string DetectLanguage()
        {
            var builder = new StringBuilder();

            if (string.IsNullOrEmpty(SourceLanguage) && string.IsNullOrEmpty(Version))
                return string.Empty;

            builder.AppendFormat("v={0}&q={1}", Version, SourceLanguage);

            return builder.ToString();
        }

        public override string SearchWebUrl()
        {
            var builder = new StringBuilder();

            if (string.IsNullOrEmpty(LanguagePair) && string.IsNullOrEmpty(Version) && string.IsNullOrEmpty(Query))
                return string.Empty;

            builder.AppendFormat("v={0}&q={1}&langpair={2}", Version, Query, LanguagePair);

            return builder.ToString();
        }
    }
}